export const CONFIG_DATA = [
  {
    defaultKey: ["default"],
    name: "command-delivery",
    summary: "mqtt-command-destination",
    idKey: "destinationId",
    formItem: [
      {
        name: "destinationId",
        value: "",
        defaultName: "名称",
        type: "input",
        required: true,
        colSpan: 24,
        validator: (rule, value, callback, list) => {
          let destinationId = [];
          list.forEach(fo => {
            destinationId.push(
              fo.attributes.find(f => f.name == "destinationId")?.value
            );
          });
          if (destinationId.filter(item => item === value).length >= 2) {
            // Vue.prototype.$msg({
            //     message: "当前配置的Destination id不能重复",
            // });
            callback(new Error("已存在同名的Destination id,请更换"));
          } else {
            callback();
          }
        }
      },
      {
        name: "protocol",
        value: "tcp",
        defaultName: "服务器地址",
        type: "select",
        options: [
          {
            name: "TCP (No Security)",
            value: "tcp"
          },
          {
            name: "TLS (Secure)",
            value: "tls"
          }
        ],
        colSpan: 13,
        required: true
      },
      {
        name: "hostname",
        value: "",
        type: "input",
        placeholder: "localhost",
        defaultName: "",
        colSpan: 11,
        required: true
      },
      {
        name: "port",
        value: 1883,
        placeholder: "1883",
        type: "inputNumber",
        defaultName: "端口",
        colSpan: 13,
        required: true
      },
      {
        name: "clientId",
        value: ``,
        type: "input",
        defaultName: "client id",
        colSpan: 24,
        required: true
      },

      {
        name: "cleanSession",
        value: true,
        defaultName: "清除会话",
        type: "switch",
        colSpan: 24,
        required: false,
        senior: true
      },
      {
        name: "qos",
        value: "",
        defaultName: "Qos",
        type: "select",
        colSpan: 24,
        options: [
          {
            name: "QoS 0 (At Most Once)",
            value: "AT_MOST_ONCE"
          },
          {
            name: "QoS 1 (At Least Once)",
            value: "AT_LEAST_ONCE"
          },
          {
            name: "QoS 2 (Exactly Once)",
            value: "EXACTLY_ONCE"
          }
        ],
        required: false,
        senior: true
      },
      {
        name: "username",
        value: "",
        defaultName: "用户名",
        type: "input",
        colSpan: 24,
        required: false,
        senior: true
      },
      {
        name: "password",
        value: "",
        defaultName: "密码",
        type: "input",
        colSpan: 24,
        required: false,
        senior: true
      },
      {
        name: "trustStorePath",
        value: "",
        defaultName: "可信赖store路径",
        type: "input",
        colSpan: 24,
        required: false,
        senior: true
      },
      {
        name: "trustStorePassword",
        value: "",
        defaultName: "可信赖store密码",
        type: "input",
        colSpan: 24,
        required: false,
        senior: true
      },
      {
        name: "keyStorePath",
        value: "",
        colSpan: 24,
        defaultName: "keystore路径",
        type: "input",
        required: false,
        senior: true
      },
      {
        name: "keyStorePassword",
        value: "",
        defaultName: "keystore密码",
        type: "input",
        colSpan: 24,
        required: false,
        senior: true
      }
    ]
  },
  {
    defaultKey: ["measurement", "location", "alert", "command", "formula"],
    name: "event-sources",
    summary: "mqtt-event-source",
    idKey: "sourceId",
    formItem: [
      {
        name: "sourceId",
        value: "",
        defaultName: "名称",
        type: "input",
        required: true,
        colSpan: 24,
        validator: (rule, value, callback, list) => {
          let sourceId = [];
          list.forEach(fo => {
            sourceId.push(fo.attributes.find(f => f.name == "sourceId")?.value);
          });
          if (sourceId.filter(item => item === value).length >= 2) {
            // Vue.prototype.$msg({
            //     message: "当前配置的Destination id不能重复",
            // });
            callback(new Error("已存在同名的sourceId id,请更换"));
          } else {
            callback();
          }
        }
      },
      {
        name: "protocol",
        value: "tcp",
        defaultName: "服务器地址",
        type: "select",
        options: [
          {
            name: "TCP (No Security)",
            value: "tcp"
          },
          {
            name: "TLS (Secure)",
            value: "tls"
          }
        ],
        colSpan: 13,
        required: true
      },
      {
        name: "hostname",
        value: "",
        type: "input",
        placeholder: "localhost",
        defaultName: "",
        colSpan: 11,
        required: true
      },
      {
        name: "port",
        value: 1883,
        placeholder: "1883",
        type: "inputNumber",
        defaultName: "端口",
        colSpan: 13,
        required: true
      },
      {
        name: "clientId",
        value: ``,
        type: "input",
        defaultName: "client id",
        colSpan: 24,
        required: true
      },

      {
        name: "topic",
        value: ``,
        type: "input",
        defaultName: "主题",
        colSpan: 24,
        required: true,
        prepend: true,
        summary: ""
      },
      {
        name: "numThreads",
        value: ``,
        type: "input",
        defaultName: "线程数",
        colSpan: 24,
        required: true
      },
      {
        name: "cleanSession",
        value: true,
        defaultName: "清除会话",
        type: "switch",
        colSpan: 24,
        required: false,
        senior: true
      },
      {
        name: "qos",
        value: "",
        defaultName: "Qos",
        type: "select",
        colSpan: 24,
        options: [
          {
            name: "QoS 0 (At Most Once)",
            value: "AT_MOST_ONCE"
          },
          {
            name: "QoS 1 (At Least Once)",
            value: "AT_LEAST_ONCE"
          },
          {
            name: "QoS 2 (Exactly Once)",
            value: "EXACTLY_ONCE"
          }
        ],
        required: false,
        senior: true
      },
      {
        name: "username",
        value: "",
        defaultName: "用户名",
        type: "input",
        colSpan: 24,
        required: false,
        senior: true
      },
      {
        name: "password",
        value: "",
        defaultName: "密码",
        type: "input",
        colSpan: 24,
        required: false,
        senior: true
      },
      {
        name: "trustStorePath",
        value: "",
        defaultName: "可信赖store路径",
        type: "input",
        colSpan: 24,
        required: false,
        senior: true
      },
      {
        name: "trustStorePassword",
        value: "",
        defaultName: "可信赖store密码",
        type: "input",
        colSpan: 24,
        required: false,
        senior: true
      },
      {
        name: "keyStorePath",
        value: "",
        colSpan: 24,
        defaultName: "keystore路径",
        type: "input",
        required: false,
        senior: true
      },
      {
        name: "keyStorePassword",
        value: "",
        defaultName: "keystore密码",
        type: "input",
        colSpan: 24,
        required: false,
        senior: true
      }
    ]
  }
];
